package com.yuju.config;

import com.weixin.mp.api.WxMpInMemoryConfigStorage;
import com.weixin.mp.api.WxMpServiceImpl;
import com.yuju.cache.RedisCache;
import com.yuju.constant.CacheKey;
import com.yuju.constant.Constant;


public class Config {
	public static WxMpServiceImpl getWxMpServiceImpl(String groupId) {
		RedisCache<String, String> cache = RedisCache.getInstance();
		WxMpInMemoryConfigStorage config = new WxMpInMemoryConfigStorage();
//		config.setAppId(WeixinConfig.AppId); // 设置微信公众号的appid
		config.setAppId(cache.get(groupId + Constant.APP_ID + CacheKey.KEY_GRP_PARAM));
		config.setSecret(cache.get(groupId + Constant.APP_SECRET + CacheKey.KEY_GRP_PARAM)); // 设置微信公众号的app
		config.setToken(WeixinConfig.token);
		WxMpServiceImpl wxService = new WxMpServiceImpl();
		wxService.setWxMpConfigStorage(config);
		return wxService;
	}
}
